package work7;

public class Library {
    Book[] books=new Library.Book[10];
    //Library的方法
    //添加书籍
    public void addBook(String title,String author){
        Book book = new Book();
        book.author=author;
        book.title=title;
        for (int i = 0; i < 10; i++) {
            if(books[i]==null){
                books[i]=book;
                break;
            }
        }
    }
    //打印books
    public void displayInfo(){
        for (Book book : books) {
            if(book!=null){
                System.out.println("书名： "+book.title+"  作者：  "+book.author);
            }
        }
    }

    static class Book{
        private String title;
        private String author;

        //

        //构造器
        public Book() {
        }
        public Book(String title, String author) {
            this.title = title;
            this.author = author;
        }
    }
}
